package com.spring.team_propaganda_system.controller;


import com.spring.team_propaganda_system.utils.ResponseEntity;
import com.spring.team_propaganda_system.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@CrossOrigin
@Controller
@RequestMapping("/hello")
@Api(value = "Hello", description = "测试接口")
public class Hello {
    @ResponseBody
    @GetMapping("/hello")
    @ApiOperation("测试是否成功")
    public ResponseEntity hello(){
        ResponseEntity responseEntity;
        responseEntity = ResponseEntity.ok();
        responseEntity.putDataValue("msg", "测试成功");
        return responseEntity;
    }

    @ResponseBody
    @GetMapping("/test1")
    @ApiOperation("测试统一异常")
    public ResponseEntity test1(){
        ResponseEntity responseEntity;
        int a=1/0;
        responseEntity = ResponseEntity.ok();
        responseEntity.putDataValue("msg", "测试统一异常成功");
        return responseEntity;
    }
    @GetMapping("/test")
    @ResponseBody
    public Result<String> demo() {
        int a=1/0;
        return Result.success("hello " );
    }
}
